package com.cntcdt.api.oauth;

import org.restlet.Request;
import org.restlet.Response;
import org.restlet.data.Form;
import org.restlet.data.MediaType;

/**
 * 
 * @author xiaog
 * 
 */
public class AccessTokenFilter extends BaseFilter {
    protected int beforeHandle(Request request, Response response) {
	Form headers = (Form) request.getAttributes().get(
		"org.restlet.http.headers");
	String access_token = headers.getFirstValue("access_token");
	if (access_token == null) {
	    response.setEntity(invalidAccessToken(MediaType.APPLICATION_JSON));
	    return STOP;
	}
	return CONTINUE;
    }
}
